package com.sevenGroup.pawnshop.service.impl;

import com.sevenGroup.pawnshop.Utils.ChangeToFunctionInfo;
import com.sevenGroup.pawnshop.controller.info.FunctionInfo;
import com.sevenGroup.pawnshop.model.Function;
import com.sevenGroup.pawnshop.dao.FunctionDao;
import com.sevenGroup.pawnshop.service.FunctionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author sevenGroup
 * @since 2022-02-16
 */
@Service
public class FunctionServiceImpl extends ServiceImpl<FunctionDao, Function> implements FunctionService {
    @Resource
    private FunctionDao functionDao;
//    通过角色ID查询功能集合
    @Override
    public List<FunctionInfo> getFunctionByRoleId(Integer rid) {
        List<Function> functions=functionDao.getFunctionByRoleId(rid);
//        转换成前端对象（此处需要单独处理，因为这是一个多级菜单）
        List<FunctionInfo> functionInfos = ChangeToFunctionInfo.copyList(functions);
        return functionInfos;
    }
}
